package com.cindata

import com.cindata.dictionary.*

class ContactSurvey implements Comparable
{
    // 借款人基本信息
    String fullName
    // 姓名
    String sex
    // 性别
    ContactIdentityType identityType
    // 证件类型
    Date birthday
    // 出身日期
    String idNumber
    // 身份证号
    String householdType
    // 户口性质
    AccountNatureDict accountNature
    // 户口类型
    String cellphone
    // 联系电话
    String phone
    // 住宅电话
    BigDecimal monthlyIncome
    // 月收入
    String zipCode
    // 邮编
    String address
    // 地址
    String workUnitName
    // 工作单位
    String workUnitAddress
    // 工作单位地址
    String maritalStatus = "未婚"
    // 婚姻状态

    //配偶
    String spouseFullName
    // 配偶姓名
    String spouseCellphone
    // 配偶联系电话
    ContactIdentityType spouseIdentityType
    // 配偶证件类型
    String spouseIdNumber
    // 配偶身份证号

    // 客户资信状况
    String creditOverdueRecord
    // 征信逾期记录：无,1-3次，3-6次，6次以上
    String creditDefaultingRecord
    // 征信违约记录：无，房贷，信用卡
    String creditSearchingTimesInHalfYear
    // 近半年征信查询次数：无,1-3次，3-6次，6次以上
    //配偶资信状况
    String spouseCreditOverdueRecord
    // 配偶征信逾期记录：无,1-3次，3-6次，6次以上
    String spouseCreditDefaultingRecord
    // 配偶征信违约记录：无，房贷，信用卡
    String spouseCreditSearchingTimesInHalfYear
    // 配偶近半年征信查询次数：无,1-3次，3-6次，6次以上

    // 负债情况
    String debtType
    // 负债类型
    Integer debtMount
    // 负债笔数
    BigDecimal loansBalance
    // 结余金额
    BigDecimal repaymentMountPerMon
    // 月均还款额
    String memo
    // 备注
    BigDecimal overdraftAmount
    // 信用卡透支金额
    BigDecimal guaranteeForOthersAmount
    // 为他人债务担保综合

    // 家庭成员收入能力检查记录
    OrganizationNatureDict workUnitNature
    // 工作单位性质
    String workUnitPhone
    // 固定电话
    String numberCheckChannel
    // 号码验证通道
    Date workUnitCheckDate
    // 核查时间
    String checkContent
    // 核查提问：是否本单位职工，职工个人情况是否吻合，员工缴存情况是否与系统对应
    String checkReceiver
    // 接听人员
    String checkReceiverIdentity
    // 身份
    String answeredSituation
    // 答复情况：核实无误，异常
    String abnormalMeno
    // 异常原因
    String actuallyCheckSituation
    // 工作单位实地核实情况

    Date fundDepositStartDate
    // 起始月份
    Date fundDepositEndDate
    // 截止月份
    Integer fundDepositDuration
    // 连续缴存期数
    BigDecimal fundDepositAmountPerMon
    // 月缴额
    BigDecimal fundDepositRatio
    // 缴存比例
    BigDecimal fundDepositBaseAmount
    // 月缴存基数
    String fundOpenedBank
    // 公积金开户行
    BigDecimal fundBalance
    // 公积金余额
    String fundAccount
    // 公积金账号

    BigDecimal monthlyTotalIncome
    // 借款人月均总收入

    Date createdDate = new Date()
    Date modifiedDate = new Date()
    User user
    User createBy
    User modifyBy

    static belongsTo = [report: ContactSurveyReport]

    static constraints = {

        fullName nullable: true, blank: true
        sex nullable: true, blank: true
        identityType nullable: true, blank: true
        birthday nullable: true, blank: true
        idNumber nullable: true, blank: true
        householdType nullable: true, blank: true
        accountNature nullable: true, blank: true
        cellphone nullable: true, blank: true
        phone nullable: true, blank: true
        monthlyIncome nullable: true, blank: true
        zipCode nullable: true, blank: true
        address nullable: true, blank: true
        workUnitName nullable: true, blank: true
        workUnitAddress nullable: true, blank: true
        maritalStatus nullable: true, blank: true
        //配偶
        spouseFullName nullable: true, blank: true
        spouseCellphone nullable: true, blank: true
        spouseIdentityType nullable: true, blank: true
        spouseIdNumber nullable: true, blank: true


        // 客户资信状况
        creditOverdueRecord nullable: true, blank: true
        creditOverdueRecord inList: ['无', '1-3次', '3-6次', '6次以上']
        creditDefaultingRecord nullable: true, blank: true
        creditDefaultingRecord inList: ['无', '房贷', '信用卡']
        creditSearchingTimesInHalfYear nullable: true, blank: true
        creditSearchingTimesInHalfYear inList: ['无', '1-3次', '3-6次', '6次以上']

        // 客户配偶资信状况
        spouseCreditOverdueRecord nullable: true, blank: true
        spouseCreditOverdueRecord inList: ['无', '1-3次', '3-6次', '6次以上']
        spouseCreditDefaultingRecord nullable: true, blank: true
        spouseCreditDefaultingRecord inList: ['无', '房贷', '信用卡']
        spouseCreditSearchingTimesInHalfYear nullable: true, blank: true
        spouseCreditSearchingTimesInHalfYear inList: ['无', '1-3次', '3-6次', '6次以上']


        // 负债情况
        debtType nullable: true, blank: true
        debtMount nullable: true, blank: true
        loansBalance nullable: true, blank: true
        repaymentMountPerMon nullable: true, blank: true
        memo nullable: true, blank: true
        overdraftAmount nullable: true, blank: true
        guaranteeForOthersAmount nullable: true, blank: true

        // 家庭成员收入能力检查记录
        workUnitNature nullable: true, blank: true
        workUnitPhone nullable: true, blank: true
        numberCheckChannel nullable: true, blank: true
        workUnitCheckDate nullable: true, blank: true
        checkContent nullable: true, blank: true
        checkReceiver nullable: true, blank: true
        checkReceiverIdentity nullable: true, blank: true
        answeredSituation nullable: true, blank: true
        abnormalMeno nullable: true, blank: true
        actuallyCheckSituation nullable: true, blank: true

        fundDepositStartDate nullable: true, blank: true
        fundDepositEndDate nullable: true, blank: true
        fundDepositDuration nullable: true, blank: true
        fundDepositAmountPerMon nullable: true, blank: true
        fundDepositRatio nullable: true, blank: true
        fundDepositBaseAmount nullable: true, blank: true
        fundOpenedBank nullable: true, blank: true
        fundBalance nullable: true, blank: true
        fundAccount nullable: true, blank: true

        monthlyTotalIncome nullable: true, blank: true

        createdDate nullable: true, blank: true
        modifiedDate nullable: true, blank: true
        user nullable: true, blank: true
        createBy nullable: true, blank: true
        modifyBy nullable: true, blank: true
    }

    @Override
    int compareTo(Object contactSurvey)
    {

        def contact = (ContactSurvey) contactSurvey
        if (id == contact.id)
        {
            return 0
        }
        else if (id > contact.id)
        {
            return 1
        }
        else
        {
            return -1
        }
    }

    def springSecurityService

    def beforeInsert()
    {
        def username = springSecurityService?.getPrincipal()?.username
        createBy = User.findByUsername(username)
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
        def username = springSecurityService?.getPrincipal()?.username
        modifyBy = User.findByUsername(username)
    }
}
